<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link type="text/css" rel="stylesheet" href="main.css">
    <!--jquery -->
	<script type="text/javascript" src="../js/jquery/jquery-2.0.3.min.js" ></script>
	
	<script type="text/javascript" src="../js/share.js"></script>
		
	<script type="text/javascript">
	var itemno = "";
	var applyid = "";
	var nodeno = "";
	var orgcode = "";
	var nextnodecode1 = "";
	var selectID = "userlist";
	var applyno = "";

	$(function(){
		applyno = getUrlParam("applyno");
		bindApply(applyno);
	})


	function bindApply(applyno){
		$.ajax({ 
			url: basePath() + 'business/getapplyinfo.do',
			data: {"applyno": applyno},
			dataType: "json",
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonApply = data.datas;
//		    		var jsonBusiness = data.datas.business;
//		    		var jsonMaterial = data.datas.material;
		    		
		    		bindApplyForm(jsonApply);
		    		
		    		//绑定业务资料
		    		bindBusinessForm(jsonApply['applyid'], jsonApply['itemno']);
//		    		
//		    		//绑定附件材料
		    		bindMaterialListForm(jsonApply['applyid']);	    
		    	}
	      	}
		});
	}

	function bindApplyForm(jsonApply){
		for(var d in jsonApply){//遍历json对象的每个key/value对,p为key
			if(d == 'applytime'){
				$('#' + d).html(formatDate(jsonApply[d], 'yyyy年mm月dd日'));
			}
			else if(d == 'nodename'){
				if(jsonApply[d] == '办结')
					$('#' + d).html('<span style="color:green;font-weight: bold;">' + jsonApply[d] + '</span>');
				else if(jsonApply[d].indexOf('补正') >= 0){
					$('#' + d).html('<span style="color:red;font-weight: bold;">' + jsonApply[d] + '</span>');
					$('#correction').show();
					$('#correction').attr('href', 'correction.html?applyno=' + applyno);
				}
				else if(jsonApply[d].indexOf('申报') >= 0){
					$('#' + d).html('<span style="color:red;font-weight: bold;">未提交</span>');
					$('#edit').show();
					$('#edit').attr('href', 'edit.html?applyno=' + applyno);
				}
	        	else if(jsonApply[d].indexOf('受理') >= 0)
	        		$('#' + d).html('<span style="color:blue; font-weight: bold;">待受理</span>');
				else{
					$('#' + d).html('<span style="color:blue;font-weight: bold;">已受理</span>');
				}
			}
			else{
				$('#' + d).html(jsonApply[d] == '' ? '/' : jsonApply[d]);
			}
		}
	}

	function bindBusinessForm(applyid, itemno){

		$.ajax({ 
			url: basePath() + 'business/getbusinessinfo.do',
			data: {"applyid": applyid, "itemno": itemno},
			dataType: "json",
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonBusiness = data.datas;
					var worktime = formatDate(jsonBusiness["workstarttime"], 'yyyy年mm月dd日')+" 至 "+formatDate(jsonBusiness["workendtime"], 'yyyy年mm月dd日');    		
					jsonBusiness["worktime"]=worktime;
					if(jsonBusiness["otherbehavior"]!=undefined&&jsonBusiness["otherbehavior"]!=''){
						jsonBusiness["business"]=jsonBusiness["business"]+"（"+jsonBusiness["otherbehavior"]+"）";
					}
					for(var d in jsonBusiness){	//遍历json对象的每个key/value对,d为key			
		    			$('#' + d).html(jsonBusiness[d] == '' ? '/' : jsonBusiness[d]);
		    		}
		    	}
	      	}
		});
		$.ajax({ 
			url: basePath() + 'business/getshipinfo.do?applyid='+applyid,
			dataType: "json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonDevice = data.datas;
					for(var i = 0; i < jsonDevice.length; i++){
						$("#shipname").html(jsonDevice[i]['shipname']);
					}
		    	}
	      	}
		});
	}

	function generator(jsonDevice){
		var builddate = formatDate(jsonDevice["builddate"], 'yyyy-mm-dd');
		var technicalparameter = "总吨位:"+jsonDevice['grosstonnage']+",净吨位:"+jsonDevice['nettonnage']+",总功率:"+jsonDevice['enginepower']+",客位:"+jsonDevice['ratedseat']+",总长:"+jsonDevice['overalllength']+",型宽:"+jsonDevice['mouldedbreadth']+",型深:"+jsonDevice['mouldeddepth']+",建造日期:"+builddate+",所有人:"+jsonDevice['owner']+",经营人:"+jsonDevice['operator'];
		return technicalparameter;
	}
	function bindMaterialListForm(applyid){

		$.ajax({ 
			url: basePath() + 'business/getmaterialinfo.do',
			data: {"applyid": applyid},
			dataType: "json",
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonMaterial = data.datas;

					var k = 1;
					for(var i = 0; i < jsonMaterial.length; i++){
						var materialname = jsonMaterial[i]['materialname'];
						
						var fileid=jsonMaterial[i]['fileid']
						if('' != fileid){
							var materialnameHmtl = k + '、' + materialname + '<br />';
							$('#material').append(materialnameHmtl);
							k++;
						}
					}
		    	}
	      	}
		});
	}

	</script>
    <style>
        table{
        border-style: solid;
        border-width: 1px;
        border-color: black;
        border-collapse: collapse;
        }
    </style>
    <title>船舶在港安全作业备案书</title>
</head>
<body>
<h1 >船舶在港安全作业备案书</h1>
<div class="编号" style="text-align: right;margin-right:570px">
    <p style="display: inline; font-size:14px;">编号：</p>
    <p style="display:inline;sfont-size: 14px;">
		<span id="applyno" style="font-size: 16px;"></span>
	</p>
</div>
<table border="1"  align="center" cellspacing="0" cellpadding="0">
    <tr>
        <td class="td-1">船舶名称</td>
        <td class="td-7" colspan="3" style="text-align: left;">
        	<span id="shipname" style=" margin-left: 10px;"></span>  
        </td>
    </tr>
    <tr>
        <td class="td-1">作业项目</td>
        <td class="td-7" colspan="3" style="text-align: left;">
        	<span id="worktypename" style=" margin-left: 10px;"></span>     	
        </td>
    </tr>
    <tr>
        <td class="td-1">作业地点</td>
        <td class="td-7" colspan="3" style="text-align: left;">
        	<span id="berth" style=" margin-left: 10px;"></span>
        </td>
    </tr>
    <tr>
        <td class="td-1">作业时间</td>
        <td class="td-7" colspan="3" style="text-align: left;">
        	<span id="worktime" style=" margin-left: 10px;"></span>
        </td>
    </tr>
     <tr>
        <td class="td-3">附送材料</td>
        <td class="td-7" colspan="3" style="text-align: left;"><p id="material" style=" margin-left: 10px;"></p></td>
    </tr>
    <tr>
        <td class="td-1">联系人</td>
        <td class="td-7" style="text-align: left;"><span id="contactperson" style=" margin-left: 10px;"></span></td>
        <td class="td-1">联系电话</td>
        <td class="td-7" style="text-align: left;"><span id="contactphone" style=" margin-left: 10px;"></span></td>
    </tr>
    <tr>
        <td class="td-1">其他<br>说明事项</td>
        <td class="td-7" colspan="3" style="text-align: left;"><span id="remark" style=" margin-left: 10px;"></span></td>
    </tr>
    <tr>
        <td colspan="4" valign="top" align="left" style="height: 150px;font-size: 16px;">
            <p align="left"  style="font-size: 16px;font-family: 'Adobe 宋体 Std L';margin-top: 10px;margin-left: 5px">兹承诺：</p>
            <p align="left"  style="font-size: 16px;font-family: 'Adobe 宋体 Std L';margin-top: 10px;margin-left: 35px;">本备案书填写的内容及提交的附送材料真实、有效。</p>
            <p align="right"  style="font-size: 16px;font-family: 'Adobe 宋体 Std L';margin-top: 15px;margin-right: 20px;">备案人签名（签章）：<span id="proposer"><span/></p>
            <p style="display: inline;padding-left: 550px;font-size:14px;"></p>
            <p id="applytime" style="display:inline;font-size: 16px;font-family: 'Adobe 宋体 Std L';margin-right: 20px;"></p>
        </td>
    </tr>
    <tr>
        <td class="td-1">备案意见</td>
        <td colspan="3" valign="top" style="height: 100px;font-size: 16px;">
            <p style="padding-left: 550px;font-size:14px;margin-top: 70px"></p>
            <p style="display:inline;margin-left:280px;font-size: 16px;font-family: 'Adobe 宋体 Std L';"></p>
            <p align="right" style="display:inline;font-size: 16px;font-family: 'Adobe 宋体 Std L';margin-left: 100px;">备案时间：</p>
            <p align="right"  style="display:inline;font-size: 16px;font-family: 'Adobe 宋体 Std L';margin-right: 100px;"></p>
        </td>
    </tr>
</table>
</body>
</html>